package com.sk.weichat.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.sk.weichat.R;

/**
* 自定义 选择相机和相册 底部弹窗
* */
public class SelectPhotoBottomDialog extends Dialog implements View.OnClickListener {
    private OnBottomDialogClickListener mOnBottomDialogClickListener;
    public SelectPhotoBottomDialog(Context context, OnBottomDialogClickListener mOnBottomDialogClickListener) {
        super(context, R.style.BottomDialog);
        this.mOnBottomDialogClickListener = mOnBottomDialogClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_check_photo);
        Window window = this.getWindow();
        window.setGravity(Gravity.BOTTOM);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);

        findViewById(R.id.tv_photo).setOnClickListener(this);
        findViewById(R.id.tv_camera).setOnClickListener(this);
        findViewById(R.id.tv_cancle).setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_photo:
                mOnBottomDialogClickListener.onClickPhoto();
                break;
            case R.id.tv_camera:
                mOnBottomDialogClickListener.onClickcamera();
                break;
            case R.id.tv_cancle:
                mOnBottomDialogClickListener.onClickCancle();
                break;
        }
    }

    public interface OnBottomDialogClickListener {
        void onClickPhoto();
        void onClickcamera();
        void onClickCancle();
    }
}
